package _021_10_5

func solve(a string) int {
	// write code here

	maxLen := 0

	for i := 0; i < len(a); i++ {
		for j := i + 1; j < len(a); j++ {
			if checkIsSym([]byte(a[i : j+1])) {
				if j-i+1 > maxLen {
					maxLen = j - i + 1
				}
			}
		}
	}
	return maxLen
}

func checkIsSym(child []byte) bool {
	if len(child)%2 == 0 {
		for i := 0; i < len(child)/2; i++ {
			if child[i] != child[len(child)/2+i] {
				return false
			}
		}
	} else {
		for i := 0; i < len(child)-1; i++ {
			if child[i] != child[i+1] {
				return false
			}
		}
	}
	return true
}
